package com.moniteach.server.db.bo;

import java.util.Date;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import org.json.JSONObject;

import com.moniteach.utils.Resource;

@PersistenceCapable
public class Task {
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Long id;

	@Persistent
	private String type;

	@Persistent
	private String title;

	@Persistent
	private String text;

	@Persistent
	private Date dateStart;

	@Persistent
	private Date dateEnd;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public Date getDateStart() {
		return dateStart;
	}

	public void setDateStart(Date dateStart) {
		this.dateStart = dateStart;
	}

	public Date getDateEnd() {
		return dateEnd;
	}

	public void setDateEnd(Date dateEnd) {
		this.dateEnd = dateEnd;
	}

	public Task(String type, String title, String text, Date dateStart,
			Date dateEnd) {
		super();
		this.type = type;
		this.title = title;
		this.text = text;
		this.dateStart = dateStart;
		this.dateEnd = dateEnd;
	}

	public JSONObject toJSONObject() {
		JSONObject jo = new JSONObject();
		jo.put(Resource.Const.type, type);
		jo.put(Resource.Const.title, title);
		jo.put(Resource.Const.text, text);
		jo.put(Resource.Const.dateStart, dateStart);
		jo.put(Resource.Const.dateEnd, dateEnd);
		return jo;
	}
}
